using System;
using System.Collections.Generic;
using Volo.Abp.EventBus.Distributed;
using Matrix.Notification.Domain.Shared.Notifications;

namespace Matrix.Notification.Events
{
    /// <summary>
    /// 通知已发送事件
    /// </summary>
    public class NotificationSentEvent     {
        /// <summary>
        /// 通知ID
        /// </summary>
        public Guid NotificationId { get; set; }

        /// <summary>
        /// 接收者
        /// </summary>
        public string Recipient { get; set; } = string.Empty;

        /// <summary>
        /// 通知渠道
        /// </summary>
        public NotificationChannel Channel { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime SentTime { get; set; }

        /// <summary>
        /// 外部ID
        /// </summary>
        public string? ExternalId { get; set; }

        /// <summary>
        /// 失败原因
        /// </summary>
        public string? FailureReason { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 批量通知已发送事件
    /// </summary>
    public class BatchNotificationSentEvent     {
        /// <summary>
        /// 批次ID
        /// </summary>
        public Guid BatchId { get; set; }

        /// <summary>
        /// 总数量
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 成功数量
        /// </summary>
        public int SuccessCount { get; set; }

        /// <summary>
        /// 失败数量
        /// </summary>
        public int FailureCount { get; set; }

        /// <summary>
        /// 跳过数量
        /// </summary>
        public int SkippedCount { get; set; }

        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime SentTime { get; set; }

        /// <summary>
        /// 总耗时（毫秒）
        /// </summary>
        public long TotalTimeMs { get; set; }

        /// <summary>
        /// 批次状态
        /// </summary>
        public string Status { get; set; } = string.Empty;

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知已删除事件
    /// </summary>
    public class NotificationDeletedEvent     {
        /// <summary>
        /// 通知ID
        /// </summary>
        public Guid NotificationId { get; set; }

        /// <summary>
        /// 接收者
        /// </summary>
        public string Recipient { get; set; } = string.Empty;

        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime DeletedTime { get; set; }

        /// <summary>
        /// 删除者ID
        /// </summary>
        public Guid? DeletedById { get; set; }

        /// <summary>
        /// 删除原因
        /// </summary>
        public string? DeleteReason { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知已读事件
    /// </summary>
    public class NotificationReadEvent     {
        /// <summary>
        /// 通知ID
        /// </summary>
        public Guid NotificationId { get; set; }

        /// <summary>
        /// 接收者ID
        /// </summary>
        public Guid RecipientId { get; set; }

        /// <summary>
        /// 阅读时间
        /// </summary>
        public DateTime ReadTime { get; set; }

        /// <summary>
        /// 阅读设备信息
        /// </summary>
        public string? DeviceInfo { get; set; }

        /// <summary>
        /// 阅读位置
        /// </summary>
        public string? ReadLocation { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知重试事件
    /// </summary>
    public class NotificationRetryEvent     {
        /// <summary>
        /// 通知ID
        /// </summary>
        public Guid NotificationId { get; set; }

        /// <summary>
        /// 当前重试次数
        /// </summary>
        public int RetryCount { get; set; }

        /// <summary>
        /// 最大重试次数
        /// </summary>
        public int MaxRetryCount { get; set; }

        /// <summary>
        /// 重试时间
        /// </summary>
        public DateTime RetryTime { get; set; }

        /// <summary>
        /// 重试原因
        /// </summary>
        public string? RetryReason { get; set; }

        /// <summary>
        /// 下次重试时间
        /// </summary>
        public DateTime? NextRetryTime { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知订阅变更事件
    /// </summary>
    public class NotificationSubscriptionChangedEvent     {
        /// <summary>
        /// 订阅ID
        /// </summary>
        public Guid SubscriptionId { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        public Guid UserId { get; set; }

        /// <summary>
        /// 通知类型
        /// </summary>
        public NotificationType NotificationType { get; set; }

        /// <summary>
        /// 通知渠道
        /// </summary>
        public NotificationChannel Channel { get; set; }

        /// <summary>
        /// 是否已订阅
        /// </summary>
        public bool IsSubscribed { get; set; }

        /// <summary>
        /// 变更时间
        /// </summary>
        public DateTime ChangedTime { get; set; }

        /// <summary>
        /// 变更类型
        /// </summary>
        public string ChangeType { get; set; } = string.Empty;

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知模板已更新事件
    /// </summary>
    public class NotificationTemplateUpdatedEvent     {
        /// <summary>
        /// 模板ID
        /// </summary>
        public Guid TemplateId { get; set; }

        /// <summary>
        /// 模板名称
        /// </summary>
        public string TemplateName { get; set; } = string.Empty;

        /// <summary>
        /// 模板类型
        /// </summary>
        public string TemplateType { get; set; } = string.Empty;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedTime { get; set; }

        /// <summary>
        /// 更新者ID
        /// </summary>
        public Guid? UpdatedById { get; set; }

        /// <summary>
        /// 更新类型
        /// </summary>
        public string UpdateType { get; set; } = string.Empty;

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }

    /// <summary>
    /// 通知统计事件
    /// </summary>
    public class NotificationStatisticsEvent     {
        /// <summary>
        /// 统计类型
        /// </summary>
        public string StatisticsType { get; set; } = string.Empty;

        /// <summary>
        /// 时间范围开始
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 时间范围结束
        /// </summary>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 总通知数
        /// </summary>
        public int TotalNotifications { get; set; }

        /// <summary>
        /// 成功通知数
        /// </summary>
        public int SuccessNotifications { get; set; }

        /// <summary>
        /// 失败通知数
        /// </summary>
        public int FailedNotifications { get; set; }

        /// <summary>
        /// 已读通知数
        /// </summary>
        public int ReadNotifications { get; set; }

        /// <summary>
        /// 统计时间
        /// </summary>
        public DateTime StatisticsTime { get; set; }

        /// <summary>
        /// 租户ID
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public Dictionary<string, object>? AdditionalData { get; set; }
    }
}